//查询用户api 可以指定用户user 也可以查询全部 
let { user } = require("../login/sign_schma.js");
module.exports = {
     userFind:async function (req, res, err) {
        let query = req.query;
        query.page = query.page?query.page:1;
        query.limit = query.limit?query.limit:10;
        let findData = query.user ? { user: query.user } : {};
        let len = await user.countDocuments(findData);

        console.log(query,456);
        user.find(
            findData,
            { passwd: false },
            { limit: Number(query.limit), skip: ((Number(query.page)-1)*Number(query.limit)) }
        ).then((data) => {
            res.send({
                data: data,
                total: len,
                limit: query.limit, 
                page: query.page,
                pages:Math.ceil(Number(len) / Number(query.limit))
            });
        })
    }
}